//
//  EXTransaction.h
//  ORM
//
//  Created by PH on 21.12.09.
//  Copyright 2009-2010 Codesign. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "EXQuery.h"
#import "EXMappableObject.h"
#import "EXPredicate.h"
#import "EXTransactionDelegate.h"

@class EXObjectStore;

@interface EXTransaction : NSObject {
	EXObjectStore* objectStore;
	NSMutableDictionary* processedObjectsForReading;
	NSMutableSet* processedObjectsForWriting;
	NSMutableDictionary* proxies;
	NSObject<EXTransactionDelegate>* delegate;
	BOOL began;
}

@property (nonatomic, retain) NSMutableDictionary* processedObjectsForReading;
@property (nonatomic, retain) NSMutableSet* processedObjectsForWriting;
@property (nonatomic, retain) NSMutableDictionary* proxies;
@property (nonatomic, retain) NSObject<EXTransactionDelegate>* delegate;
@property (nonatomic) BOOL began;

- (id)initWithObjectStore:(EXObjectStore*)_objectStore;
- (BOOL)commit;
- (BOOL)rollback;
- (void)begin;
- (BOOL)storeObject:(NSObject<EXMappableObject>*)object;
- (BOOL)removeObject:(NSObject<EXMappableObject>*)object;
- (id)objectWithObjectID:(NSString*)objectID;
- (NSArray*)objectsOfClass:(Class)cls;
- (NSArray*)objectsOfClass:(Class)cls filter:(EXQuery*)query;
- (NSArray*)proxiesOfClass:(Class)cls;
- (NSArray*)objectsWithPredicate:(EXPredicate*)predicate;
- (NSArray*)proxiesWithPredicate:(EXPredicate*)predicate;

@end
